package com.github.data_manage

import com.fasterxml.jackson.databind.ObjectMapper
import com.github.data_manage.controller.FundChartController
import com.github.data_manage.dao.FundDao
import com.github.data_manage.domain.po.FundDepthResearch
import com.github.data_manage.domain.po.FundDepthResearchAttach
import com.github.data_manage.domain.vo.BatchFundContrastDataQueryVo
import com.github.data_manage.service.FundDeepResearchService
import kotlinx.coroutines.runBlocking
import org.junit.jupiter.api.Test
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.test.context.SpringBootTest
import java.math.BigDecimal
import java.math.RoundingMode
import kotlin.time.measureTime

@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
class DepthResearchInfoTest {

    @Autowired
    lateinit var fundDeepResearchService: FundDeepResearchService

    @Autowired
    lateinit var fundDao: FundDao

    @Autowired
    lateinit var objectMapper: ObjectMapper

    @Autowired
    lateinit var fundChartController: FundChartController

    @Test
    fun fundTest() {
//        val fund = fundDao.findById(2103).orElseThrow()
//        val fundDepthResearch: FundDepthResearch = FundDepthResearch(fund.fundId!!)
//        fundDeepResearchService.handleDepthResearchInfo(fund, fundDepthResearch)
//        println(objectMapper.writeValueAsString(fundDepthResearch))
        BigDecimal.ZERO.divide(BigDecimal.ONE, 2, RoundingMode.HALF_UP)
        println(FundDepthResearchAttach.propertyIndexMap.size)
        val attaches = mutableListOf<FundDepthResearchAttach>()
        val depthResearchAttach = FundDepthResearchAttach()
        attaches.add(depthResearchAttach)
        depthResearchAttach.fundId = 10;
        println()
    }

    @Test
    fun fundQueryTest() {
        val batchFundContrastDataQueryVo = BatchFundContrastDataQueryVo()
        batchFundContrastDataQueryVo.baseFundId = 2202
        batchFundContrastDataQueryVo.contrastIds = listOf(62)
        val time = measureTime {
            val value = fundChartController.twelveRollingPerformanceMetricsBetaAndCorrel(batchFundContrastDataQueryVo)
            println(objectMapper.writeValueAsString(value))
        }
        println("time = $time")
    }
}
